//
//  RootTabBarController.m
//  第九节作业
//
//  Created by dllo on 16/3/21.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "RootTabBarController.h"
#import "NaviGationTabBarOfFirst.h"
#import "ViewController.h"
#import "SecondView.h"
#import "Thiredview.h"
#import "NavigationTabBarOfSecond.h"
#import "NavigationTabBarOfThird.h"
@interface RootTabBarController ()

@end

@implementation RootTabBarController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.viewControllers = [self createRootOfVCS];
    }
    
    return self;
}



- (NSArray<UIViewController *> *)createRootOfVCS{
    //创建一个可变数组
    NSMutableArray *mArrOfVCS = [NSMutableArray array];
    //创建一个vc对象
    ViewController *vc = [[ViewController alloc]init];
    //创建一个Navigation对象并且添加到vc视图上
    NaviGationTabBarOfFirst *navi = [[NaviGationTabBarOfFirst alloc]initWithRootViewController:vc];
    //将navigation放到数组中
    [mArrOfVCS addObject:navi];
    //内存管理
    [vc release];
    [navi release];
    //创建一个tabBarItem对象,并且创建他的样式和tag值
    navi.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"First" image:[UIImage imageNamed:@"yi"] tag:100];
    //在tabBarItem中添加角标
    navi.tabBarItem.badgeValue = @"99+";
    
    
    //创建第二个tabBarItem对象
    SecondView *second = [[SecondView alloc]init];
    NavigationTabBarOfSecond *navi2 = [[NavigationTabBarOfSecond alloc]initWithRootViewController:second];
    [mArrOfVCS addObject:navi2];
    
    navi2.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"Second" image:[UIImage imageNamed:@"er"] tag:200];
    [navi2 release];
    [second release];
    
    //创建第三个tabBarItem对象
    Thiredview *third = [[Thiredview alloc]init];
    NavigationTabBarOfThird *navi3 = [[NavigationTabBarOfThird alloc]initWithRootViewController:third];
    [mArrOfVCS addObject:navi3];
    navi3.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"Third" image:[UIImage imageNamed:@"san"] tag:300];
    [third release];
    [navi3 release];
    
    
    
    return mArrOfVCS;
}


















- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    
    
}























































- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
